/**
 * 
 */
package org.simpleProxy;

import java.io.File;
import java.io.IOException;
import java.util.concurrent.LinkedBlockingQueue;

import org.apache.ftpserver.ftplet.FtpException;
import org.apache.log4j.Logger;

/**
 * @author Brad Glasbergen
 *
 */
public class JavaFTPProxy {

	/**
	 * @param args
	 * @throws FtpException 
	 * @throws IOException 
	 */
	
	//The logger
	static Logger classLogger = Logger.getLogger(JavaFTPProxy.class.getName());
	
	//The linked queue for pushing files to the actual ftp server
	static LinkedBlockingQueue<String> filesToPush = new LinkedBlockingQueue<String>();
	
	public static void main(String[] args) throws FtpException, IOException {
		
		
		// Set the Log4J options - Read from file if it exists or use default
		LoggingConfigurator cfg = new LoggingConfigurator(new File("log4j.xml"));
		classLogger.info("Done setting logging properties; continuing");
		
		// Try to read the configuration file, otherwise use defaults
		BasicConfigurator bcfg = new BasicConfigurator("server.cfg");
		String ftpFolder = bcfg.ftpFolder;
		int portNumber = bcfg.ftpPort;
		
		
		//Launch the FTP server - use properties for credentials on provided port.
		Server server = new Server(new File("users.properties"), portNumber, ftpFolder);
		server.start();
		FileHandler handler = new FileHandler();
		handler.start();
	}

}
